package leetcodecompetition.S107;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Siantar
 * @Date: 2023-06-24-23:31
 * @Description: 1.0
 */
public class T6895 {
    List<int[]> list = new ArrayList<int[]>() {{
        add(new int[]{1});
        add(new int[]{0, 2});
        add(new int[]{0, 2});
    }};

    public int longestString(int x, int y, int z) {
        int res = 0;
        res = Math.max(res, dfs(0, new int[]{x - 1, y, z}));
        res = Math.max(res, dfs(1, new int[]{x, y - 1, z}));
        res = Math.max(res, dfs(2, new int[]{x, y, z - 1}));
        return res * 2;
    }

    public int dfs(int pre, int[] xyz) {
        int res = 0;
        int[] t = list.get(pre);
        for (int i : t) {
            if (xyz[i] > 0) {
                int[] xyzTmp = xyz;
                xyzTmp[i]--;
                res = Math.max(res, dfs(i, xyzTmp) + 1);
            }
        }
        System.out.println(res);
        return res;
    }

    @Test
    public void test() {
        System.out.println(longestString(3, 2, 2));
    }
}
